// pages/examinationlist/examinationlist.js
import http from '../../utils/requestAnalysis'
// import https from '../../utils/request'
Page({

    /**
     * 页面的初始数据
     */
    data: {
        endstartlist:[]
    },
    async jumppage(e) {
        //console.log(e.currentTarget.dataset.item, 'oooooooooooooooooo');
        let that = this
        if(wx.getStorageSync('studentToken')){
        //   let id = JSON.parse(wx.getStorageSync('token')).id
        //   if (e.currentTarget.dataset.item.lookType == 0) {
        //     // let id = JSON.parse(wx.getStorageSync('studentToken')).id
        //     let options={
        //               url:'/nav/getSelectScoreType',
        //                 method:'POST',
        //               data:{navId: e.currentTarget.dataset.item.navId},
        //                 header:{"content-type":"application/json;charset=UTF-8"}
        //         }
        //         let res = await http(options)
        //         //console.info(res)
        //         if(res.data.code==0){
        //             if (res.data.obj == 0) {
        //                 let arr = []
        //                 that.data.endstartlist.map(ress => {
        //                     if (ress.navId == e.currentTarget.dataset.item.navId) {
        //                         ress.lookType = 1
        //                     }
        //                     arr.push(ress)
        //                 })
        //                 this.setData({
        //                     endstartlist: arr
        //                 })
        //                 wx.showToast({
        //                     icon: 'none',
        //                     title: '考试阅卷未结束，请根据老师通知查询成绩',
        //                     duration: 5000 //持续的时间
        //                 })
        //                 return
        //             }
        //             wx.setStorageSync('examinationInfo',JSON.stringify(e.currentTarget.dataset.item))
        //             wx.navigateTo({
        //                 url: '/pages/learningsituationreport/learningsituationreport',
        //             })
        //         }else{
        //             wx.showToast({
        //             title: res.data.msg,
        //             icon: 'none',
        //             duration: 2000 //持续的时间
        //             })
        //         }
        //   } else {
        //     wx.showToast({
        //         icon: 'none',
        //         title: '考试阅卷未结束，请根据老师通知查询成绩',
        //         duration: 5000 //持续的时间
        //     })
        //     return
        //   }
            wx.setStorageSync('examinationInfo',JSON.stringify(e.currentTarget.dataset.item))
            wx.navigateTo({
                url: '/pages/learningsituationreport/learningsituationreport',
            })
        }else{
          wx.redirectTo({
            url: '/pages/newstudentlogin/newstudentlogin',
          })
        }
    },
    async endmytask(){
        let that = this
        if(wx.getStorageSync('studentToken')){
        //   let id = JSON.parse(wx.getStorageSync('token')).id
          let id = JSON.parse(wx.getStorageSync('studentToken')).id
          let options={
                  url:'/analysis/score/examMainList',
                    method:'GET',
                  data:{},
                    header:{"content-type":"application/json;charset=UTF-8"}
            }
            let res = await http(options)
            //console.info(res)
            if(res.data.code==200){
                // if(res.data.obj.info=='考试已结束'){
                //     this.setData({endstartlist:''})
                //     return false
                // }
                let arr = []
                res.data.data.map(ress => {
                    let obj = ress
                    obj.lookType = 0
                    arr.push(obj)
                })
                this.setData({endstartlist:arr})
                //console.log(res.data, 'vvvvvvvvvvvvv')
            }else{
                wx.showToast({
                title: res.data.msg,
                icon: 'none',
                duration: 2000 //持续的时间
                })
            }
        }else{
          wx.redirectTo({
            url: '/pages/newstudentlogin/newstudentlogin',
          })
        }
      },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.endmytask()
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})